package com.example.mydemo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class HelpActivity extends Activity implements View.OnClickListener{

    private ImageView img1;
    private ImageView img2;
    private LinearLayout linearLayout1;
    private LinearLayout linearLayout2;
    private LinearLayout linearLayout3;
    private TextView tv1;
    private TextView tv2;
    private TextView tv3;
    private TextView tv4;
    private TextView tv5;
    private TextView tv6;
    private TextView tv7;
    private TextView tv8;

    public void intentText(String str, String str2) {
        Intent intent = new Intent(this, HelpTextActivity.class);
        intent.putExtra("title", str);
        intent.putExtra("data", str2);
        startActivityForResult(intent, 1);
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        android.util.Log.d("lfy","[HelpActivity] onCreate......");
        setContentView(R.layout.activity_help);

        linearLayout1 = (LinearLayout) findViewById(R.id.ln_1);
        linearLayout2 = (LinearLayout) findViewById(R.id.ln_2);
        linearLayout3 = (LinearLayout) findViewById(R.id.ln_3);
        img1 = (ImageView) findViewById(R.id.img_1);
        img2 = (ImageView) findViewById(R.id.img_2);
        tv1 = (TextView) findViewById(R.id.dicas_text);
        tv2 = (TextView) findViewById(R.id.text2);
        tv3 = (TextView) findViewById(R.id.text3);
        tv4 = (TextView) findViewById(R.id.text4);
        tv5 = (TextView) findViewById(R.id.text5);
        tv6 = (TextView) findViewById(R.id.text6);
        tv7 = (TextView) findViewById(R.id.text7);
        tv8 = (TextView) findViewById(R.id.text8);

        tv2.setOnClickListener(this);
        tv3.setOnClickListener(this);
        tv4.setOnClickListener(this);
        tv5.setOnClickListener(this);
        tv6.setOnClickListener(this);
        tv7.setOnClickListener(this);
        tv8.setOnClickListener(this);
        linearLayout1.setOnClickListener(this);
        linearLayout2.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.text2:
                HelpActivity.this.intentText(getApplicationContext().getResources().getString(R.string.text2),
                        getApplicationContext().getResources().getString(R.string.text2_desc));
                break;
            case R.id.text3:
                HelpActivity.this.intentText(getApplicationContext().getResources().getString(R.string.text3),
                        getApplicationContext().getResources().getString(R.string.text3_desc));
                break;
            case R.id.text4:
                HelpActivity.this.intentText(getApplicationContext().getResources().getString(R.string.text4),
                        getApplicationContext().getResources().getString(R.string.text4_desc));
                break;
            case R.id.text5:
                HelpActivity.this.intentText(getApplicationContext().getResources().getString(R.string.text5),
                        getApplicationContext().getResources().getString(R.string.text5_desc));
                break;
            case R.id.text6:
                HelpActivity.this.intentText(getApplicationContext().getResources().getString(R.string.text6),
                        getApplicationContext().getResources().getString(R.string.text6_desc));
                break;
            case R.id.text7:
                HelpActivity.this.intentText(getApplicationContext().getResources().getString(R.string.text7),
                        getApplicationContext().getResources().getString(R.string.text7_desc_1));
                break;
            case R.id.text8:
                HelpActivity.this.intentText(getApplicationContext().getResources().getString(R.string.text8),
                        getApplicationContext().getResources().getString(R.string.text8_desc_1));
                break;
            case R.id.ln_1:
                if (HelpActivity.this.tv1.getVisibility() == View.GONE) {
                    HelpActivity.this.img1.setImageResource(R.drawable.ic_up_open);
                    HelpActivity.this.tv1.setVisibility(View.VISIBLE);
                    return;
                }
                HelpActivity.this.img1.setImageResource(R.drawable.ic_down_close);
                HelpActivity.this.tv1.setVisibility(View.GONE);
                break;
            case R.id.ln_2:
                if (HelpActivity.this.linearLayout3.getVisibility() == View.GONE) {
                    HelpActivity.this.img2.setImageResource(R.drawable.ic_up_open);
                    HelpActivity.this.linearLayout3.setVisibility(View.VISIBLE);
                    return;
                }
                HelpActivity.this.img2.setImageResource(R.drawable.ic_down_close);
                HelpActivity.this.linearLayout3.setVisibility(View.GONE);
        }
    }
}
